package tournamentmanager;

import junit.framework.AssertionFailedError;

public class MockMatchRunner extends AbstractMatchRunner {

  private int expectedGamesToPlay;

  private int count;

  private final StringBuffer playedMatches = new StringBuffer();

  private String expectedMatches;

  public void run() {
    playedMatches.append(whitePlayer.getName());
    playedMatches.append("-");
    playedMatches.append(blackPlayer.getName());
    count++;
  }

  public void verify() {
    if (expectedGamesToPlay != count) {
      throw new AssertionFailedError("Expected: " + expectedGamesToPlay
              + " Actual: " + count);
    }
    if (!playedMatches.toString().equals(expectedMatches)) {
      throw new AssertionFailedError("Expected: " + expectedMatches
              + " Actual: " + playedMatches.toString());

    }
  }

  public void setExpectedGamesToPlay(int expectedGamesToPlay) {
    this.expectedGamesToPlay = expectedGamesToPlay;
  }

  public void setExpectedMatches(String expectedMatches) {
    this.expectedMatches = expectedMatches;
  }
}
